<?php

/**
 * @author Barkowsky Igor
 * @copyright 2008
 * @filesource index.php
 * @subpackage news admin
 */
$per_page = 20;
$lim_from = $from*$per_page;
$table=$db->pfx."comments";
$mod_path = $this->fetchPath($this->path);
if(isset($mod_path[0]) and intval($mod_path[0])!=0) $item_id = intval($mod_path[0]);
if(isset($item_id))
{
	$item = $db->fetch_one("SELECT * FROM $table WHERE id = '$item_id'");
	if($item['image']=='1') $item['photo']=UPLOAD.$this->dir."/".$item['id'];
	else $item['photo']=false;
	$do='edit';
	$smarty->assign("item",$item);
}
else $do='add';
$items = $db->fetch_array("SELECT SQL_CALC_FOUND_ROWS * FROM $table ORDER BY time DESC LIMIT $lim_from,$per_page");
if($items!=false)
{
	$quantity = $db->fetch_one(QUANTITY);
	$per_page_navigation = per_page_navigation($quantity[0],$per_page,$from);
	if($quantity[0]>0)
	{
		foreach($items as $k=>$v)
		{
			switch($v['module'])
			{
				case 'flash':
					$element = $db->fetch_one("SELECT * FROM $db->pfx"."flash_games WHERE id = '".$v['obj_id']."'");
					if($element != false and !empty($element))
					{
						$items[$k]['object_admin_full_path'] = 'flash/'.$element['id'].'.html';
						$items[$k]['object_site_full_path'] = $element['alias'].'.html';
						$items[$k]['item'] = $element;
					}
				break;
			}
			if(intval($v['user_id']) != 0)
			{
				$rating_user = $db->fetch_one("SELECT * FROM $db->pfx"."users WHERE user_id = '".$v['user_id']."'");
				if($rating_user != false and !empty($rating_user))
				{
					$items[$k]['user_admin_full_path'] = 'users/'.$rating_user['user_id'].'.html';
					$items[$k]['user_site_full_path'] = 'users/'.$rating_user['login'].'.html';
					$items[$k]['user'] = $rating_user;
				}
			}
		}
		$smarty->assign("items_kolvo",$quantity[0]);
		$smarty->assign("items",$items);
	}
}
?>